<template>
  <el-form :model="form" label-width="100px" size="mini">
    <div class="form-title">基本信息</div>
    <el-row>
      <el-col :span="12">
        <el-form-item label="上报部门" prop="deptName">
          {{form.deptName}}
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="录入人" prop="createUserName">
          {{form.createUserName}}
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="路线名称" prop="roadName">
          {{form.roadName || "---"}}
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="位置桩号" prop="locationNum">
          {{form.locationNum || "--"}}
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="排查方向" prop="troubleshootingDirection">
          {{form.troubleshootingDirection || "---"}}
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="排查时间" prop="troubleshootingTime">
          {{form.troubleshootingTime || "---"}}
        </el-form-item>
      </el-col>
    </el-row>
    <div class="form-title">工作明细</div>
    <el-row>
      <el-col :span="12">
        <el-form-item label="项目类型" prop="taskType">
          {{form.taskType == 1?"定额项目":"定额外项目"}}
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="类型" prop="iTroubleshooting">
          {{getCheckTypeName(form.iTroubleshooting)}}
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="作业项目" prop="beyondQuota">
          <span>{{ form.quantitativeTypeName }}</span><span>【 </span>{{form.quantitativeTypeValue}}<span>/</span>{{form.quantitativeRatedUnitValue}}<span>/人/天 】</span>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-form-item label="自有人员" prop="ownPersonnel">
          {{form.personalUsername}}
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="外包人数" prop="outSourceNum">
          {{form.outSourceNum || 0}} （ 人 ）
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="完成时间" prop="acceptanceDays">
          {{form.acceptanceDays}}  （ 天 ）
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="完成工作量" prop="taskNum">
          {{form.taskNum}} （ <dict-tag :options="dict.type.jl_case_unit" :value="form.numUnit"></dict-tag>）
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="合格工作量" prop="qualifiedNum">
          {{form.qualifiedNum}} （ <dict-tag :options="dict.type.jl_case_unit" :value="form.numUnit"></dict-tag>）
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="材料使用量" prop="materialUsage">
          {{form.materialUsage}}
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-form-item label="情况简单描述" prop="description">
          {{form.description}}
        </el-form-item>
      </el-col>
    </el-row>
     <div class="form-title">施工照片</div>
    <el-row>
      <el-col :span="24">
        <el-form-item label="施工前照片" prop="picIdsBegin">
          <image-upload v-model="form.picIdsBegin" :isShowTip="!isDisabled" :limit="100" :fileSize="1000" :isDisabled="isDisabled" />
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-form-item label="施工中照片" prop="picIdsMiddle">
          <image-upload v-model="form.picIdsMiddle" :isShowTip="!isDisabled" :limit="100" :fileSize="1000" :isDisabled="isDisabled" />
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-form-item label="施工后照片" prop="picIdsEnd">
          <image-upload v-model="form.picIdsEnd" :isShowTip="!isDisabled" :limit="100" :fileSize="1000" :isDisabled="isDisabled" />
        </el-form-item>
      </el-col>
    </el-row>
    <el-row v-if="!operating && dataStatus <= 2">
      <div class="form-title">审核信息</div>
      <el-col :span="12">
        <el-form-item label="审核人" prop="auditUserName">
          {{form.auditUserName + "（工区主任）"}}
        </el-form-item>
      </el-col>
    </el-row>
    <template v-else-if="!operating">
      <div class="form-title">审核信息</div>
      <el-row>
        <el-col :span="12">
          <el-form-item label="审核人" prop="auditUserId">
            {{ form.auditUserName + "（工区主任）"}}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="审核结果" prop="dataStatus">
            {{form.dataStatus == 4?'驳回':'同意'}}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item :label="form.dataStatus ==4? '驳回原因':'审核意见'" prop="auditMessage">
            {{ form.auditMessage }}
          </el-form-item>
        </el-col>
      </el-row>
    </template>
  </el-form>
</template>

<script>
import { listCommonCheckType } from '@/api/cases/commonCheckType'

export default {
  dicts: ["jl_cases_damage_level", "jl_cases_repair_method", "jl_data_status", "jl_measurement_unit","jl_case_unit"],
  data() {
    return {
      visible: false,
      isDisabled: true,
      checkTypes: []
    }
  },
  props: {
    form: {
      type: Object,
      default: () => {
        return {}
      }
    },
    dataStatus: {
      type: [String, Number],
      default: void 0
    },
    operating:{
      type:Boolean,
      default:false
    }
  },
  created() {
    this.getCheckTypes()
  },
  methods: {
    /**
     * 获取类型
     */
    getCheckTypes() {
      let params = {
        status: 0,
        delFlag: 0
      }
      return new Promise((resolve, reject) => {
        listCommonCheckType(params).then(res => {
          this.checkTypes = res.data;
          resolve()
        }).catch(() => {
          this.checkTypes = [];
          reject()
        })
      })
    },
    /**
     * 获取检查的名称
     */
    getCheckTypeName(checkType) {
      let index = this.checkTypes.findIndex((item) => {
        return item.id == checkType;
      })
      if (index > -1) {
        return this.checkTypes[index].checkTypeName
      } else {
        return ""
      }
    },
  }
}
</script>

<style lang="scss" scoped>
.form-title {
  padding: 2px 0;
  border-bottom: 1px solid #eee;
  margin-bottom: 10px;
}
.input-sperator {
  margin-right: 10px;
  margin-left: 10px;
  padding-bottom: 18px;
  line-height: 29px;
}
</style>